<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use app\common\model\AboutAdvantageModel;
use app\common\model\AboutCertificateHonorModel;
use app\common\model\AboutPurposeModel;
use app\common\model\AdsModel;
use app\common\model\CompanyModel;
use app\common\model\NewsModel;
use app\common\model\ProjectCategoryModel;
use app\common\model\ProjectModel;
use app\common\model\SolutionModel;

class Index extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = 'default';

    public function _initialize()
    {
        parent::_initialize();
        
        $this->assign('keywords','浙江微享');
        $this->assign('description','浙江微享');

    }

    public function index(AdsModel $AdsModel, ProjectModel $ProjectModel, NewsModel $NewsModel)
    {
        $ads = $AdsModel->getList(1);
        $this->assign('ads',$ads);

        // 网站案例列表
        $case_pc_list = $ProjectModel->getIndexList(2,6);
        $this->assign('case_pc_list',$case_pc_list);

        // 手机端案例列表
        $case_wap_list = $ProjectModel->getIndexList('1,3',5);
        $this->assign('case_wap_list',$case_wap_list);

        $news_list = $NewsModel->getList(3);
        $this->assign('news_list',$news_list);

        return $this->view->fetch();
    }

    public function about(AdsModel $AdsModel, AboutPurposeModel $AboutPurposeModel, AboutCertificateHonorModel $AboutCertificateHonorModel, AboutAdvantageModel $AboutAdvantageModel, ProjectModel $ProjectModel)
    {
        $ads = $AdsModel->getAds(2);
        $this->assign('ads',$ads);
        $about_purpose = $AboutPurposeModel->getList();
        $this->assign('about_purpose',$about_purpose);
        $about_certificate_honor = $AboutCertificateHonorModel->getList();
        $this->assign('about_certificate_honor',$about_certificate_honor);
        $about_advantage = $AboutAdvantageModel->getList();
        $this->assign('about_advantage',$about_advantage);
        $project = $ProjectModel->getAboutList();
        $this->assign('project',$project);
        return $this->view->fetch();
    }

    public function solve(AdsModel $AdsModel,SolutionModel $SolutionModel)
    {
        $ads = $AdsModel->getAds(3);
        $this->assign('ads',$ads);
        $solution = $SolutionModel->getList();
        $this->assign('solution',$solution);
        return $this->view->fetch();
    }

    public function case(AdsModel $AdsModel, ProjectModel $ProjectModel, ProjectCategoryModel $ProjectCategoryModel)
    {

        $cate_id = $this->request->param('cate_id',0);
        $page = $this->request->param('page',1);

        // banner
        $ads = $AdsModel->getAds(4);
        $this->assign('ads',$ads);
        // 推荐案例
        $project_recommend = $ProjectModel->getProjectRecommend($cate_id);
        $this->assign('project_recommend',$project_recommend);
        // 案例腰栏banner1
        $ads_case_1 = $AdsModel->getList(7);
        $this->assign('ads_case_1',$ads_case_1);
        // 案例腰栏banner2
        $ads_case_2 = $AdsModel->getList(8);
        $this->assign('ads_case_2',$ads_case_2);
        // 案例分类
        $category = $ProjectCategoryModel->getList();
        $this->assign('category',$category);
        // 案例列表
        $project_page_list = $ProjectModel->getPageList($cate_id,$page);
        $this->assign('project_page_list',$project_page_list);

        $this->assign('cate_id',$cate_id);
        return $this->view->fetch();
    }

    public function caseDetail(AdsModel $AdsModel, ProjectModel $ProjectModel)
    {
        $id = $this->request->param('id');

        // banner
        $ads = $AdsModel->getAds(4);
        $this->assign('ads',$ads);
        // 案例列表
        $project = $ProjectModel->getDetail($id);
        $this->assign('project',$project);

        return $this->view->fetch();
    }

    public function news(AdsModel $AdsModel, NewsModel $NewsModel)
    {
        $page = $this->request->param('page',1);

        // banner
        $ads = $AdsModel->getAds(5);
        $this->assign('ads',$ads);
        $news_page_list = $NewsModel->getPageList($page);
        $this->assign('news_page_list',$news_page_list);

        return $this->view->fetch();
    }

    public function newsdetail(AdsModel $AdsModel, NewsModel $NewsModel)
    {
        $id = $this->request->param('id');
        $ads = $AdsModel->getAds(5);
        $this->assign('ads',$ads);
        $news = $NewsModel->getDetail($id);
        $this->assign('news',$news);
        return $this->view->fetch();
    }

    public function contact(AdsModel $AdsModel, CompanyModel $CompanyModel)
    {
        // banner
        $ads = $AdsModel->getAds(6);
        $this->assign('ads',$ads);
        $company = $CompanyModel->getList();
        $this->assign('company',$company);

        return $this->view->fetch();
    }

}
